﻿using System.ComponentModel;
using System.Drawing.Design;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TemplateFoundation.UI.WebControls
{
    /// <summary>
    /// Used to add a list box control when creating user interfaces for the EPiServer UI
    /// </summary>
    public class DropDownList : PagePropertyStyleControlBase
    {
        private System.Web.UI.WebControls.DropDownList _dropDownList = new System.Web.UI.WebControls.DropDownList();

        /// <summary>
        /// Creates a new DropDownList control
        /// </summary>
        public DropDownList()
        {
            _dropDownList.Attributes.Add("style", "width: 246px");
        }

        /// <summary>
        /// Creates the property control to render
        /// </summary>
        public override Control CreatePropertyControl()
        {
            return _dropDownList;
        }

        /// <summary>
        /// Gets the client ID of the value control
        /// </summary>
        public string ValueControlId
        {
            get
            {
                return _dropDownList.ClientID;
            }
        }

        /// <summary>
        /// Provides access to embedded DropDownList control property
        /// </summary>
        public ListItemCollection Items
        {
            get
            {
                return _dropDownList.Items;
            }
        }

        /// <summary>
        /// Provides access to embedded DropDownList control property
        /// </summary>
        public int SelectedIndex
        {
            get
            {
                return _dropDownList.SelectedIndex;
            }
            set
            {
                _dropDownList.SelectedIndex = value;
            }
        }

        /// <summary>
        /// Provides access to embedded DropDownList control property
        /// </summary>
        public string SelectedValue
        {
            get
            {
                return _dropDownList.SelectedValue;
            }
            set
            {
                _dropDownList.SelectedValue = value;
            }
        }

        /// <summary>
        /// Provides access to embedded DropDownList control property
        /// </summary>
        public string DataMember
        {
            get
            {
                return _dropDownList.DataMember;
            }
            set
            {
                _dropDownList.DataMember = value;
            }
        }

        /// <summary>
        /// Provides access to embedded DropDownList control property
        /// </summary>
        public object DataSource
        {
            get
            {
                return _dropDownList.DataSource;
            }
            set
            {
                _dropDownList.DataSource = value;
            }
        }

        /// <summary>
        /// Provides access to embedded DropDownList control property
        /// </summary>
        public string DataSourceID
        {
            get
            {
                return _dropDownList.DataSourceID;
            }
            set
            {
                _dropDownList.DataSourceID = value;
            }
        }

        /// <summary>
        /// Provides access to embedded DropDownList control property
        /// </summary>
        public IDataSource DataSourceObject
        {
            get
            {
                return _dropDownList.DataSourceObject;
            }
        }

        /// <summary>
        /// Provides access to embedded DropDownList control property
        /// </summary>
        public string DataTextField
        {
            get
            {
                return _dropDownList.DataTextField;
            }
            set
            {
                _dropDownList.DataTextField = value;
            }
        }

        /// <summary>
        /// Provides access to embedded DropDownList control property
        /// </summary>
        public string DataTextFormatString
        {
            get
            {
                return _dropDownList.DataTextFormatString;
            }
            set
            {
                _dropDownList.DataTextFormatString = value;
            }
        }

        /// <summary>
        /// Provides access to embedded DropDownList control property
        /// </summary>
        public string DataValueField
        {
            get
            {
                return _dropDownList.DataValueField;
            }
            set
            {
                _dropDownList.DataValueField = value;
            }
        }

        /// <summary>
        /// Provides access to embedded DropDownList control property
        /// </summary>
        public bool AutoPostBack
        {
            get
            {
                return _dropDownList.AutoPostBack;
            }
            set
            {
                _dropDownList.AutoPostBack = value;
            }
        }
    }
}
